package com.bawei.park2302.house

import com.bawei.lib_base.utils.utils.mvi.BaseViewModel
import com.bawei.lib_base.utils.utils.request.RequestType
import com.bawei.lib_base.utils.utils.utils.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HouseViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel<HouseIntent>(){
    override fun handelIntent(it: HouseIntent) {
        when(it){
            is HouseIntent.house -> httpRequest(apiService.house(),RequestType.APPROVE)

            is HouseIntent.houseRegionId -> httpRequest(apiService.houseRegionId(it.regionId))

            is HouseIntent.houseRent -> httpRequest(apiService.houseRent(it.id,it.rentDate),RequestType.RENT)

            is HouseIntent.houseUnRent -> httpRequest(apiService.houseUnRent(it.id),RequestType.UN_RENT)

            else -> {}
        }
    }
}